﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
@* 查看人员 *@
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<link rel="stylesheet" href="https://cdn.staticfile.org/layui/2.6.8/css/layui.css">
<script src="https://cdn.staticfile.org/layui/2.6.8/layui.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
</head>
<body>

    <form class="layui-form">
        <div class="layui-form-item">

            <div class="layui-inline">

                <div class="layui-form-item">
                    <label class="layui-form-label">性别</label>
                    <div class="layui-input-block">
                        <input type="radio" name="persSex" value="男" title="男">
                        <input type="radio" name="persSex" value="女" title="女">
                    </div>
                </div>


                <div class="layui-input-block">
                        <select name="city" id="education" lay-filter="aihao">
                         <option value="">请选择学历</option>
                        <option value="博士">博士</option>
                        <option value="硕士">硕士</option>
                        <option value="本科">本科</option>
                        <option value="大专">大专</option>
                        <option value="中专">中专</option>
                        <option value="高中">高中</option>
                        <option value="初中">初中</option>
                        <option value="小学">小学</option>
                        <option value="其他">其他</option>
                        </select>
                </div>

                
                <div class="layui-input-inline layui-input-wrap">
                        <input type="text"  id="persCard" placeholder="请输入" class="layui-input demo-phone">
                </div>


                 <div class="layui-input-inline layui-input-wrap">
                     <input type="text"  id="persPhone" placeholder="请输入" class="layui-input demo-phone">
                </div>


                 <div class="layui-input-block">
                        <select name="city" id="departmentId" lay-filter="aihao">
                         <option value="">请选择</option>
                        <option value="1">测试部</option>
                        <option value="2">秘书部</option>
                        <option value="3">组织部</option>
                        </select>
                </div>
                  

                 @* <input type="text" id="persCard" placeholder="（必填）" class="layui-input-inline layui-input-wrap"> *@


                <h2>基础信息</h2>
                <hr class="layui-border-green">
                <table>
                    <tr>
                        <td>

                            <label class="layui-form-label">姓名：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="basicName" placeholder="请输入姓名" class="layui-input">
                            </div>

                        </td>
                        <td>

                            <label class="layui-form-label">曾用名：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="basicFormer" placeholder="请输入内容" class="layui-input">
                            </div>

                        </td>
                    </tr>

                    <tr>
                        <td>

                            <label class="layui-form-label">证件类型</label>
                            <div class="layui-input-block">
                                <select id="card" lay-filter="aihao">
                                    <option value="">请选择证件类型</option>
                                    <option value="身份证">身份证</option>
                                    <option value="护照">护照</option>
                                    <option value="军官证">军官证</option>
                                    <option value="士兵证">士兵证</option>
                                    <option value="港澳台往来通行证">港澳台往来通行证</option>
                                    <option value="警官证">警官证</option>
                                    <option value="外国人永久居留证">外国人永久居留证</option>
                                    <option value="边民出入通行证">边民出入通行证</option>
                                    <option value="其他">其他</option>
                                </select>
                            </div>

                        </td>
                        <td>

                            <label class="layui-form-label">证件号：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="basicCard" placeholder="请输入证件号" class="layui-input">
                            </div>

                        </td>
                    </tr>

                    <tr>
                        <td>

                            <label class="layui-form-label">性别：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="basicSex" value="男" title="男">
                                <input type="radio" name="basicSex" value="女" title="女">

                            </div>

                        </td>
                        <td>

                            <label class="layui-form-label">出生日期</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="date" id="basicbirth" lay-verify="date" autocomplete="off" class="layui-input">
                            </div>

                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div>
                                <label class="layui-form-label">籍贯</label>
                                <div class="layui-input-block">
                                    <select id="provinceId" lay-filter="provincet">
                                        <option value="">请选择</option>
                                    </select>
                                </div>
                                <div class="layui-input-block">
                                    <select id="directlyId" lay-filter="city">
                                        <option value="">请选择</option>
                                    </select>
                                </div>

                                <div class="layui-input-block">
                                    <select id="countyId" lay-filter="directly">
                                        <option value="">请选择</option>
                                    </select>
                                </div>

                            </div>

                        </td>
                        <td>

                            <label class="layui-form-label">政治面貌：</label>
                            <div class="layui-input-block">
                                <select id="politic" lay-filter="aihao">
                                    <option value="">请选择政治面貌</option>
                                    <option value="无党派">无党派</option>
                                    <option value="群众">群众</option>
                                    <option value="共产党员">共产党员</option>
                                    <option value="共青团员">共青团员</option>
                                    <option value="民主党派">民主党派</option>
                                    <option value="中国民工民主党">中国民工民主党</option>
                                    <option value="中国民主同盟">中国民主同盟</option>
                                    <option value="中国民主建国会">中国民主建国会</option>
                                    <option value="中国致公党">中国致公党</option>
                                </select>
                            </div>

                        </td>
                    </tr>

                    <tr>
                        <td>
                            <label class="layui-form-label">民族：</label>
                            <div class="layui-input-block">
                                <select id="nationId" lay-filter="aihao">
                                    <option value="">请选择民族</option>
                                    <option value="汉族">汉族</option>
                                    <option value="壮族">壮族</option>
                                    <option value="满族">满族</option>
                                    <option value="回族">回族</option>
                                    <option value="苗族">苗族</option>
                                    <option value="维吾尔族">维吾尔族</option>
                                    <option value="土家族">土家族</option>
                                    <option value="蒙古族">蒙古族</option>
                                    <option value="白族">白族</option>
                                </select>
                            </div>
                        </td>
                        <td>
                            <label class="layui-form-label">户口性质：</label>
                            <div class="layui-input-block">
                                <select id="household" lay-filter="aihao">
                                    <option value="">请选择户口性质</option>
                                    <option value="农业">农业</option>
                                    <option value="非农业">非农业</option>
                                </select>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div>
                                <label class="layui-form-label">所在区域</label>
                                <div class="layui-input-block">
                                    <select id="provinceId1" lay-filter="provincet1">
                                        <option value="">请选择</option>
                                    </select>
                                </div>
                                <div class="layui-input-block">
                                    <select id="directlyId1" lay-filter="city1">
                                        <option value="">请选择</option>
                                    </select>
                                </div>

                                <div class="layui-input-block">
                                    <select id="countyId1" lay-filter="directly1">
                                        <option value="">请选择</option>
                                    </select>
                                </div>

                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" id="basicName" placeholder="请输入" class="layui-input">
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <label class="layui-form-label">参加工作时间：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="date" id="basicPartici" lay-verify="date" autocomplete="off" class="layui-input">
                            </div>
                        </td>

                        <td>
                            <label class="layui-form-label">最新体验时间：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="date" id="basicPhysical" lay-verify="date" autocomplete="off" class="layui-input">
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <label class="layui-form-label">最后毕业院校：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="basicGraduate" placeholder="请输入最后毕业院校" class="layui-input">
                            </div>
                        </td>

                        <td>
                            <label class="layui-form-label">最高学历：</label>
                            <div class="layui-input-block">
                                <select id="education" lay-filter="aihao">
                                    <option value="">请选择最高学历</option>
                                    <option value="大专">大专</option>
                                    <option value="本科">本科</option>
                                    <option value="博士">博士</option>
                                    <option value="硕士">硕士</option>
                                </select>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <label class="layui-form-label">毕业时间：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="date" id="basicGradate" lay-verify="date" autocomplete="off" class="layui-input">
                            </div>
                        </td>

                        <td>
                            <label class="layui-form-label">招聘渠道：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="basicChannel" placeholder="请输入招聘渠道" class="layui-input">
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <label class="layui-form-label">婚姻状况：</label>
                            <div class="layui-input-block">
                                <select id="marriage" lay-filter="aihao">
                                    <option value="">请选择婚姻状况</option>
                                    <option value="未婚">未婚</option>
                                    <option value="已婚">已婚</option>
                                    <option value="离异">离异</option>
                                    <option value="丧偶">丧偶</option>
                                </select>
                            </div>
                        </td>

                        <td>
                            <label class="layui-form-label">结婚纪念日：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="date" id="basicWedd" lay-verify="date" autocomplete="off" class="layui-input">
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <label class="layui-form-label">是否外籍：</label>
                            <div class="layui-input-block">
                                <select id="foreignId" lay-filter="aihao">
                                    <option value="">请选择外籍</option>
                                    <option value="非外籍">非外籍</option>
                                    <option value="外籍">外籍</option>
                                </select>
                            </div>
                        </td>

                        <td>
                            <label class="layui-form-label">最高职称：</label>
                            <div class="layui-input-block">
                                <select id="basictech" lay-filter="aihao">
                                    <option value="">请选择职称</option>
                                    <option value="研发人员">研发人员</option>
                                    <option value="项目经理">项目经理</option>
                                    <option value="总经理">总经理</option>
                                    <option value="区域负责人">区域负责人</option>
                                </select>
                            </div>
                        </td>

                    </tr>

                    <tr>
                        <td>
                            <label class="layui-form-label">身高：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="basicstature" placeholder="请输入身高" class="layui-input">
                            </div>
                        </td>

                        <td>
                            <label class="layui-form-label">体重：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="basicsWigth" placeholder="请输入体重" class="layui-input">
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <label class="layui-form-label">血型：</label>
                            <div class="layui-input-block">
                                <select id="basicBlood" lay-filter="aihao">
                                    <option value="">请选择血型</option>
                                    <option value="A型">A型</option>
                                    <option value="B型">B型</option>
                                    <option value="AB型">AB型</option>
                                    <option value="O型">O型</option>
                                </select>
                            </div>
                        </td>

                        <td>
                            <label class="layui-form-label">健康状态：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="basicPhys" placeholder="请输入健康状态" class="layui-input">
                            </div>
                        </td>

                    </tr>

                    <tr>
                        <td>
                            <label class="layui-form-label">外语：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="basicforeign" placeholder="请输入外语" class="layui-input">
                            </div>
                        </td>

                        <td>
                            <label class="layui-form-label">外语水平：</label>
                            <div class="layui-input-inline layui-input-wrap">
                                <input type="text" id="basicLanguage" placeholder="请输入外语水平" class="layui-input">
                            </div>
                        </td>
                    </tr>


                </table>
                <input type="button" class="layui-btn" lay-submit lay-filter="demo1" onclick="Cancel()" value="取消" />
                <input type="button" class="layui-btn" lay-submit lay-filter="demo1" onclick="add()" value="保存" />



            </div>

        </div>
    </form>
</body>
</html>

<script>

    layui.use('form',function () {
        var table = layui.table;
        var form = layui.form;
        var layer = layui.layer;

            bangsheng();
            bangsheng1();
            FantRY();

        //省
        function bangsheng() {
            $.ajax({
                url: "http://localhost:5123/api/Regions/ProvinceQuerys",
                data: JSON.stringify({}),
                type: "post",
                async: false,
                dataType: "json",
                contentType: "application/json",
                success: res => {
                    console.log(res)
                    $.each(res.data, function () {
                        $("#provinceId").append(`<option value="${this.provinceId}">${this.provinceName}</option>`);
                    })
                    form.render('select'); // 重新渲染下拉框
                }

            })
        }
        var provincetId1 = 0;
        var cityid = 0;
        form.on('select(provincet)', function (data) {
            provincetId1 = data.value;
            console.log(provincetId1)
            $("#directlyId").empty();
            $("#directlyId").append(`<option value="">请选择</option>`);
            $("#countyId").empty();
            $("#countyId").append(`<option value="">请选择</option>`);
            bangshi()

        });
        form.on('select(city)', function (data) {
            cityid = data.value;
            console.log(provincetId1)
            $("#countyId").empty();
            $("#countyId").append(`<option value="">请选择</option>`);
            bangxian();

        });

        //市
        function bangshi() {
            var provinceId = $("#provinceId").val();
            $.ajax({
                url: "http://localhost:5123/api/Regions/CityQuerys",
                data: JSON.stringify({ provinceId: provincetId1 }),
                type: "post",
                async: false,
                dataType: "json",
                contentType: "application/json",
                success: res => {

                    console.log(res.data)
                    $.each(res.data, function () {

                        $("#directlyId").append(`<option value="${this.directlyId}">${this.directlyName}</option>`);
                    })
                    form.render('select'); // 重新渲染下拉框
                }

            })
        }
        //县
        function bangxian() {
            var directlyId = $("#directlyId").val();
            $.ajax({
                url: "http://localhost:5123/api/Regions/CountyQuerys",
                data: JSON.stringify({ directlyId: cityid }),
                type: "post",
                async: false,
                dataType: "json",
                contentType: "application/json",
                success: res => {

                    $.each(res.data, function () {
                        $("#countyId").append(`<option value="${this.countyId}">${this.countyName}</option>`);
                    })
                    form.render('select'); // 重新渲染下拉框
                }

            })
        }



        //省1
        function bangsheng1() {
            $.ajax({
                url: "http://localhost:5123/api/Regions/ProvinceQuerys",
                data: JSON.stringify({}),
                type: "post",
                async: false,
                dataType: "json",
                contentType: "application/json",
                success: res => {
                    console.log(res)
                    $.each(res.data, function () {
                        $("#provinceId1").append(`<option value="${this.provinceId}">${this.provinceName}</option>`);
                    })
                    form.render('select'); // 重新渲染下拉框
                }

            })
        }
        var provincetId1 = 0;
        var cityid1 = 0;
        form.on('select(provincet1)', function (data) {
            provincetId1 = data.value;
            console.log(provincetId1)
            $("#directlyId1").empty();
            $("#directlyId1").append(`<option value="">请选择</option>`);
            $("#countyId1").empty();
            $("#countyId1").append(`<option value="">请选择</option>`);
            bangshi1()

        });
        form.on('select(city1)', function (data) {
            cityid1 = data.value;
            console.log(provincetId1)
            $("#countyId1").empty();
            $("#countyId1").append(`<option value="">请选择</option>`);
            bangxian1();

        });

        //市1
        function bangshi1() {
            var provinceId1 = $("#provinceId1").val();
            $.ajax({
                url: "http://localhost:5123/api/Regions/CityQuerys",
                data: JSON.stringify({ provinceId: provincetId1 }),
                type: "post",
                async: false,
                dataType: "json",
                contentType: "application/json",
                success: res => {

                    console.log(res.data)
                    $.each(res.data, function () {
                        $("#directlyId1").append(`<option value="${this.directlyId}">${this.directlyName}</option>`);
                    })
                    form.render('select'); // 重新渲染下拉框
                }

            })
        }
        //县1
        function bangxian1() {
            var directlyId1 = $("#directlyId1").val();
            $.ajax({
                url: "http://localhost:5123/api/Regions/CountyQuerys",
                data: JSON.stringify({ directlyId: cityid1 }),
                type: "post",
                async: false,
                dataType: "json",
                contentType: "application/json",
                success: res => {

                    $.each(res.data, function () {
                        $("#countyId1").append(`<option value="${this.countyId}">${this.countyName}</option>`);
                    })
                    form.render('select'); // 重新渲染下拉框
                }

            })
        }


        //反填
        function FantRY() {
            var persId = localStorage.getItem("persId")
            $.ajax({
                url: 'http://localhost:5123/api/UsersInterface/FantianPersonnel',
                type: 'post',
                data: JSON.stringify({ persId: persId }),
                dataType: "json",
                contentType: "application/json",
                success: res => {
                    $(res.data).each(function () {
                        console.log(this)
                        $('input[name="persSex"][value="' + this.persSex + '"]').prop('checked', true);
                        form.render('radio');
                        //$("[name=persSex][value=" + this.persSex + "]").prop("checked", true)
                        $("#education").val(this.education);
                        $("#persCard").val(this.persCard);
                        $("#persPhone").val(this.persPhone);
                        $("#departmentId").val(this.departmentId);
                        form.render('select');
                    })
                }
            })
        }


    });


    function add() {
        //添加
        var data = {
            basicName: $("#basicName").val(),
            basicFormer: $("#basicFormer").val(),
            card: $("#card").val(),
            basicCard: $("#basicCard").val(),
            basicSex: $("[name=basicSex]:checked").val(),
            basicbirth: $("#basicbirth").val(),
            //籍贯
            provinceIdjiGuan: $("#countyId").val(),
            politic: $("#politic").val(),
            nationId: $("#nationId").val(),
            household: $("#household").val(),
            //户口所在地
            provinceId: $("#provinceId").val(),
            basicAddress: $("#countyId1").val(),
            basicPartici: $("#basicPartici").val(),
            basicPhysical: $("#basicPhysical").val(),
            basicGraduate: $("#basicGraduate").val(),
            education: $("#education").val(),
            basicGradate: $("#basicGradate").val(),
            basicChannel: $("#basicChannel").val(),
            marriage: $("#marriage").val(),
            basicWedd: $("#basicWedd").val(),
            foreignId: $("#foreignId").val(),
            basictech: $("#basictech").val(),
            basicstature: $("#basicstature").val(),
            basicsWigth: $("#basicsWigth").val(),
            basicBlood: $("#basicBlood").val(),
            basicPhys: $("#basicPhys").val(),
            basicforeign: $("#basicforeign").val(),
            basicLanguage: $("#basicLanguage").val(),
        }
        $.ajax({
            url: 'http://localhost:5123/api/UsersInterface/AddBasicInfo',
            type: 'post',
            data: JSON.stringify(data),
            dataType: "json",
            contentType: "application/json",
            success: res => {
                if (res.code == 0) {
                    layer.msg(res.msg);
                }
                else {
                    layer.msg(res.msg);
                }
            }
        })
    }



</script>
